﻿<?php
class ShoesController extends Controller {
var $name = 'Shoes';
var $uses = array("Shoe");

function index($id){
//$comics = array ("jedna", "dva", "tři");
if(isset($id)){$this->Shoe->delete($id);}
$mojeprom = "Boty";
$this->set('nazev', $mojeprom);
$boty=$this->Shoe->find('all');
$this->set('boty', $boty);
//debug($boty);

}

function detail($id){
//echo $id;
$conds=array('Shoe.id' => $id);
$result = $this->Shoe->find('all',array('conditions'=>$conds));
$this->set('boty', $result);
//debug($result);

}
function edit($id){
/*
$this->Shoe->id= $id;
$this->Shoe->save($this->data);
*/
$conds=array('Shoe.id' => $id);
$result = $this->Shoe->find('all',array('conditions'=>$conds));
$options = array(
    "černé" => "černé",
    "červené" => "červené",
	"modré" => "modré",
	"bílé" => "bílé",
);
$options2 = array(
    "kopačky" => "kopačky",
    "žabky" => "žabky",
	"sandále" => "sandále",
);
$options3 = array(
    "ano" => "ano",
    "ne" => "ne",
	);
$options4 = array(
   'tkaničky'=>'tkaničky', 'zip'=>'zip','suchý zip'=>'suchý zip');


foreach($result as $pom){
$this->set('result', $pom['Shoe']);
}
$this->set('id', $id);
$this->set('options2', $options2);
$this->set('options', $options);
$this->set('options3', $options3);
$this->set('options4', $options4);
$this->set('options4', $options4);

}
function edited($id){
if(isset($this->data)){
$this->Shoe->id=$id;
if($this->Shoe->save($this->data)){
$this->set('save', true);}
   else { $this->set('save', false);}

   }
}
function add(){
//zde si posílám možnosti do comboboxu a radiobuttonu a vytahávám je zpět a ukládám do DB
$options = array(
    "černé" => "černé",
    "červené" => "červené",
	"modré" => "modré",
	"bílé" => "bílé",
);
$options2 = array(
    "kopačky" => "kopačky",
    "žabky" => "žabky",
	"sandále" => "sandále",
);
$options3 = array(
    "ano" => "ano",
    "ne" => "ne",
	);
$options4 = array(
   'tkaničky'=>'tkaničky', 'zip'=>'zip','suchý zip'=>'suchý zip');
$this->set('options2', $options2);
$this->set('options', $options);
$this->set('options3', $options3);
$this->set('options4', $options4);
if(isset($this->data['Shoe']['barva'])){
$this->data['Shoe']['barva']=$options[$this->data['Shoe']['barva']];
$this->data['Shoe']['zapinani']=$options4[$this->data['Shoe']['zapinani']];
$this->data['Shoe']['typ']=$options2[$this->data['Shoe']['typ']];
$this->data['Shoe']['podpatky']=$options3[$this->data['Shoe']['podpatky']];
}
//debug($this->data);
if(isset($this->data)){
if($this->Shoe->save($this->data)){
$this->set('save', true);}
   else { $this->set('save', false);}

   }}
}
?>